#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
int is_legal(char arr[],int len)
{
	int i = 0;
	int count1 = 0;
	int count2 = 0;
   if(arr[0] > '0' && arr[0] < '9')
	   return 0;
   if(len < 8)
	   return 0;
   for(i=0;i<len;i++)
   {
       if((arr[i] > '9' && arr[i] < 'A') || (arr[i] > 'Z' && arr[i] < 'a') || (arr[i] > 'z'))
	   {
	       return 0;
	   }
	   if(arr[i] > 'A' && arr[i] < 'Z')
	   {
	       count1++;
	   }
	   if(arr[i] > 'a' && arr[i] < 'z')
	   {
	       count2++;
	   }
   }
   if(count1 == len)
	   return 0;
   if(count2 == len)
	   return 0;
   return 1;
}
int main ()
{
	int n = 0;
	char arr[101] = {0};
	int len = 0;

	scanf("%d",&n);
	while(n)
	{
	    scanf("%s",arr);
	    len = strlen(arr);
	    if(is_legal(arr,len) == 0)
			printf("NO\n");
		else
			printf("YES\n");
		n--;
	}
    return 0;
}